package com.jade.editor.domain.parts;

import java.awt.Polygon;
import java.io.File;

import org.eclipse.core.runtime.IPath;
import org.eclipse.jface.window.Window;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.swt.widgets.ToolItem;
import org.eclipse.wb.swt.ResourceManager;
import org.eclipse.wb.swt.SWTResourceManager;

import com.jade.editor.domain.ani.Anisotropy;
import com.jade.editor.domain.ani.AnisotropyModel;
import com.jade.editor.domain.ani.PlacementMng;

public class ToolBarSide {
	
	public final static int TOOL_SELECT = 0;
	public final static int TOOL_POINT = 1;
	public final static int TOOL_LINE = 2;
	
	private DrawArea _drawArea;
	private boolean _showGridFlag = false;
	private boolean _showBGImgFlag = false;
	private boolean _showAniFlag = false;
	private boolean _showRulerFlag = false;
	private boolean _showSettingsTabFlag = false;
	private int _metricGrid = DrawArea.METRIC_PX;
	private IPath _filePath;
	private String _selectedImageName = null;
	private int _toolSelected = TOOL_SELECT;
	private Anisotropy _ani = null;
	private String _lastUsedAni = "";
	private String _lastTypeAni = "";
//	private ObjectEditor _editor = null;
//	private ObjectModel _objModel = null;
	
	public ToolBarSide(Composite parent, DrawArea drawArea, IPath filePath/*, ObjectEditor editor, ObjectModel objModel*/){
		createPartControl(parent);
//		_editor = editor;
//		_objModel = objModel;
		_filePath = filePath;
		_drawArea = drawArea;
		
		if(_drawArea != null)
			_drawArea.initArea();
		else{
			_drawArea.setParent(parent);
//			_drawArea.setObjectModel(_objModel);
//			_drawArea.setEditor(_editor);
			_drawArea.initArea();
		}
		
//		if(_objModel.getBGColor() != null){
//			_drawArea.setBGColor(_objModel.getBGColor());
//			_drawArea.setBGStatus(DrawArea.BACKGROUND_COLOR);
//		}
//		if(_objModel.getBGImagePath() != null && !_objModel.getBGImagePath().equals("") && _objModel.getBGImageLocation() != null){
//			_drawArea.setBGImageLocation(_objModel.getBGImageLocation());
//			File img = new File(_objModel.getBGImagePath());
//			_drawArea.setBGImage(img);
//			_selectedImageName = img.getName();
//			_drawArea.setBGStatus(DrawArea.BACKGROUND_IMAGE);
//		}
		
	}

	public void addToolBar(Composite parent, DrawArea drawArea){
		createPartControl(parent);
	}
	
	
	
	private void createPartControl(Composite parent){
		final Composite toolBarLayer = new Composite(parent, SWT.NONE);
		toolBarLayer.setBounds(0, 0, 26, 370);
		toolBarLayer.setBackground(SWTResourceManager.getColor(SWT.COLOR_WIDGET_BACKGROUND));
		toolBarLayer.setLayout(null);
		
		//------------------------------------
		//-----------Show Bars----------------
		//------------------------------------
		ToolBar toolBarShowGrid = new ToolBar(toolBarLayer, SWT.WRAP | SWT.RIGHT | SWT.VERTICAL);
		toolBarShowGrid.setBounds(0, 0, 24, 22);
				
		final ToolItem itemShowGrid = new ToolItem(toolBarShowGrid, SWT.RADIO);
		itemShowGrid.setImage(ResourceManager.getPluginImage("com.jade.editor.object", "icons/IMG_GRID.png"));
		itemShowGrid.setToolTipText("Show Grid");
		itemShowGrid.setSelection(_showGridFlag);
		itemShowGrid.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				if(_showGridFlag) {
					_showGridFlag = false;
					_drawArea.showGrid(false);
				}
				else {
					_showGridFlag = true;
					_drawArea.showGrid(true);
				}
						
				itemShowGrid.setSelection(_showGridFlag);
			}
		});
				
		//------------------------------------
				
		ToolBar toolBarShowRuler = new ToolBar(toolBarLayer, SWT.WRAP | SWT.RIGHT | SWT.VERTICAL);
		toolBarShowRuler.setBounds(0, 22, 24, 22);
		
		final ToolItem itemShowRuler = new ToolItem(toolBarShowRuler, SWT.RADIO);
		itemShowRuler.setImage(ResourceManager.getPluginImage("com.jade.editor.object", "icons/IMG_RULER.png"));
		itemShowRuler.setToolTipText("Show Ruler");
		itemShowRuler.setSelection(_showRulerFlag);
		itemShowRuler.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				if(_showRulerFlag) {
					_showRulerFlag = false;
					_drawArea.setRulerVisible(false);
				}
				else {
					_showRulerFlag = true;
					_drawArea.setRulerVisible(true);
				}
				
				itemShowRuler.setSelection(_showRulerFlag);
			}
		});
		
		//------------------------------------
				
		ToolBar toolBarShowAni = new ToolBar(toolBarLayer, SWT.WRAP | SWT.RIGHT | SWT.VERTICAL);
		toolBarShowAni.setBounds(0, 44, 24, 22);
			
		final ToolItem itemShowAni = new ToolItem(toolBarShowAni, SWT.RADIO);
		itemShowAni.setImage(ResourceManager.getPluginImage("com.jade.editor.object", "icons/IMG_ANISOTROPY.png"));
		itemShowAni.setToolTipText("Show Anisotropy");
		itemShowAni.setSelection(_showAniFlag);
		itemShowAni.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				if(_showAniFlag) _showAniFlag = false;
				else _showAniFlag = true;
				
				itemShowAni.setSelection(_showAniFlag);
			}
		});
			
		//------------------------------------
		
		ToolBar toolBarShowBG = new ToolBar(toolBarLayer, SWT.WRAP | SWT.RIGHT | SWT.VERTICAL);
		toolBarShowBG.setBounds(0, 66, 24, 22);
		
		final ToolItem itemShowBG = new ToolItem(toolBarShowBG, SWT.RADIO);
		itemShowBG.setImage(ResourceManager.getPluginImage("com.jade.editor.object", "icons/IMG_BG.png"));
		itemShowBG.setToolTipText("Show Background Image");
		itemShowBG.setSelection(_showBGImgFlag);
		itemShowBG.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				
				_showBGImgFlag = _showBGImgFlag ? false : true;
				_drawArea.showBGImage(_showBGImgFlag);
					
				itemShowBG.setSelection(_showBGImgFlag);
			}
		});
		
		//------------------------------------
		//-----------Settings Bar-------------
		//------------------------------------
		ToolBar toolBarEditor = new ToolBar(toolBarLayer, SWT.FLAT | SWT.RIGHT | SWT.VERTICAL);
		toolBarEditor.setBounds(0, 91, 24, 66);
		
		ToolItem itemGridSettings = new ToolItem(toolBarEditor, SWT.PUSH);
		itemGridSettings.setImage(ResourceManager.getPluginImage("com.jade.editor.object", "icons/IMG_GRID_SETTINGS.png"));
		itemGridSettings.setToolTipText("Grid Settings");
		itemGridSettings.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				SettingsGrid sg = new SettingsGrid(toolBarLayer.getShell(), _drawArea.getGridDistanse(), _drawArea.getGridColor(), _metricGrid);
				sg.open();
				if(sg.getReturnCode() == Window.OK){
					_metricGrid = sg.getMetrics();
					_drawArea.setGridColor(sg.getColor());
					_drawArea.setGridDistanse(sg.getDistanse());
				}
				
			}
		});
		
		ToolItem itemBGimageSettings = new ToolItem(toolBarEditor, SWT.PUSH);
		itemBGimageSettings.setImage(ResourceManager.getPluginImage("com.jade.editor.object", "icons/IMG_BG_SETTINGS.png"));
		itemBGimageSettings.setToolTipText("Background settings");
		itemBGimageSettings.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				SettingsBG sBG = new SettingsBG(
						toolBarLayer.getShell(),
						_filePath,
						_drawArea.getBGStatus(),
						_drawArea.getDrawAreaSize(),
						_drawArea.getGridDistanse(),
						_drawArea.getBGColor(),
						_drawArea.getBGImageLocation(),
						_selectedImageName
						);
				sBG.open();
				
				if (sBG.getReturnCode() == Window.OK){
					if (sBG.getBGStatus() == DrawArea.BACKGROUND_COLOR){
						_drawArea.setBGColor(sBG.getBGColor());
					}
					if (sBG.getBGStatus() == DrawArea.BACKGROUND_IMAGE){
						_drawArea.setBGImageLocation(sBG.getImgLocation());
						_drawArea.setBGImage(sBG.getBGImage());
						_selectedImageName = sBG.getSelectedImageName();
					}
//					_editor.setDirty(true);
					_drawArea.setBGStatus(sBG.getBGStatus());
				}
				
				
			}
		});
		
		ToolItem itemAniSettings = new ToolItem(toolBarEditor, SWT.PUSH);
		itemAniSettings.setImage(ResourceManager.getPluginImage("com.jade.editor.object", "icons/IMG_ANISOTROPY _SETTINGS.png"));
		itemAniSettings.setToolTipText("Anisotropy Settings");
		itemAniSettings.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				SettingsAni sa = new SettingsAni(toolBarLayer.getShell(), _filePath, _lastUsedAni, _lastTypeAni);
				sa.open();
				if (sa.getReturnCode() == Window.OK){
					
					if (sa.getLastUsedType().equals(SettingsAni.ANI_TYPE_PLUGABLE)){
						//TODO Plugable
						
						_ani = new Anisotropy(sa.getPluginLocation(), _drawArea.getDrawAreaSize());
						_drawArea.setAnisotropy(_ani);
						_lastUsedAni = sa.getLastUsedName();
						_lastTypeAni = sa.getLastUsedType();
					}
					else if (sa.getLastUsedType().equals(SettingsAni.ANI_TYPE_DRAWABLE)){
						_ani = new Anisotropy(new AnisotropyModel(sa.getSelectedAni().getPath()),  _drawArea.getDrawAreaSize()); 
						
						//TODO move this down
						_drawArea.setAnisotropy(_ani);
						_lastUsedAni = sa.getLastUsedName();
						_lastTypeAni = sa.getLastUsedType();
					}
					//here
					
				}
			}
		});
		
		//------------------------------------
		//-----------Object Settings Bar------
		//------------------------------------
		ToolBar toolBarObjSettings = new ToolBar(toolBarLayer, SWT.WRAP | SWT.RIGHT | SWT.VERTICAL);
		toolBarObjSettings.setBounds(0, 161, 24, 44);
		
		ToolItem itemObjectSettingsTool = new ToolItem(toolBarObjSettings, SWT.PUSH);
		itemObjectSettingsTool.setImage(ResourceManager.getPluginImage("com.jade.editor.object", "icons/IMG_OBJECT.png"));
		itemObjectSettingsTool.setToolTipText("Object Settings");
		itemObjectSettingsTool.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
//				SettingsObject so = new SettingsObject(
//						toolBarLayer.getShell(),
//						_drawArea.getNodeCollector().getBorderColor(),
//						_drawArea.getNodeCollector().getSelectionColor(),
//						_drawArea.getNodeCollector().getConnectionColor(),
//						_drawArea.getNodeCollector().getFillColor(),
//						_drawArea.getNodeCollector().getPoleColor(),
//						_drawArea.getNodeCollector().getPoleSelectionColor(),
//						_drawArea.getNodeCollector().isFilled(),
//						_drawArea.getDrawAreaSize().x,
//						_drawArea.getDrawAreaSize().y);
//				so.open();
//				if (so.getReturnCode() == Window.OK){
//					_drawArea.getNodeCollector().setBorderColor(so.getBorderColor());
//					_drawArea.getNodeCollector().setSelectionColor(so.getSelectionColor());
//					_drawArea.getNodeCollector().setConnectionColor(so.getConnectionColor());
//					_drawArea.getNodeCollector().setFillColor(so.getFilledColor());
//					_drawArea.getNodeCollector().setPoleColor(so.getPoleColor());
//					_drawArea.getNodeCollector().setPoleSelectionColor(so.getPoleSelectionColor());
//					_drawArea.getNodeCollector().fillPolygon(so.getFilled());
//					_drawArea.setDrawAreaSize(so.getSize());
//					_editor.setDirty(true);
//				}
			}
		});
		
		ToolItem itemHoleSettingsTool = new ToolItem(toolBarObjSettings, SWT.PUSH);
		itemHoleSettingsTool.setImage(ResourceManager.getPluginImage("com.jade.editor.domain", "icons/CARD.png"));
		itemHoleSettingsTool.setToolTipText("Domain Settings");
		itemHoleSettingsTool.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				SettingsDomain sd = new SettingsDomain(toolBarLayer.getShell(), _drawArea.getDrawAreaSize());
				sd.open();
				if(sd.getReturnCode() == Window.OK){
					_drawArea.setDrawAreaSize(sd.getSize());
					if(_ani != null)
						_ani.setSize(sd.getSize());
					_drawArea.getDrawAreaComposite().redraw();
				}
			}
		});
		
		//------------------------------------
		//-----------Run Bar---------------
		//------------------------------------

		
		
		ToolBar toolBarRun = new ToolBar(toolBarLayer, SWT.FLAT | SWT.RIGHT | SWT.VERTICAL);
		toolBarRun.setBounds(0, 209, 24, 66);
		
		ToolItem itemRun = new ToolItem(toolBarRun, SWT.PUSH);
		itemRun.setImage(ResourceManager.getPluginImage("com.jade.editor.domain", "icons/IMG_RUN.png"));
		itemRun.setToolTipText("Run");
		itemRun.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				PlacementMng pm = new PlacementMng(toolBarLayer.getShell(), _drawArea, _filePath.toFile()); //TODO Run
				pm.open();
			}
		});
		
		//------------------------------------
		//-----------Zoom Bar-----------------
		//------------------------------------
		ToolBar toolBarZoom = new ToolBar(toolBarLayer, SWT.FLAT | SWT.RIGHT | SWT.VERTICAL);
		toolBarZoom.setBounds(0, 279, 24, 88);
		
		ToolItem itemZoomIn = new ToolItem(toolBarZoom, SWT.PUSH);
		itemZoomIn.setImage(ResourceManager.getPluginImage("com.jade.editor.object", "icons/IMG_ZOOM_IN.png"));
		itemZoomIn.setToolTipText("Zoom In");
		itemZoomIn.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				
			}
		});
		
		ToolItem itemZoomOut = new ToolItem(toolBarZoom, SWT.PUSH);
		itemZoomOut.setImage(ResourceManager.getPluginImage("com.jade.editor.object", "icons/IMG_ZOOM_OUT.png"));
		itemZoomOut.setToolTipText("Zoom Out");
		itemZoomOut.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				
			}
		});
		
		ToolItem itemZoomFit = new ToolItem(toolBarZoom, SWT.PUSH);
		itemZoomFit.setImage(ResourceManager.getPluginImage("com.jade.editor.object", "icons/IMG_ZOOM_FIT.png"));
		itemZoomFit.setToolTipText("Fit to Editor");
		itemZoomFit.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				
			}
		});
		
		ToolItem itemZoom100 = new ToolItem(toolBarZoom, SWT.PUSH);
		itemZoom100.setImage(ResourceManager.getPluginImage("com.jade.editor.object", "icons/IMG_ZOOM_100.png"));
		itemZoom100.setToolTipText("Zoom to 100%");
		
		//------------------------------------
		//-----------Separators---------------
		//------------------------------------
		
		Label separatorH1 = new Label(toolBarLayer, SWT.SEPARATOR | SWT.HORIZONTAL);
		separatorH1.setBounds(0, 89, 26, 2);
		
		Label separatorH2 = new Label(toolBarLayer, SWT.SEPARATOR | SWT.HORIZONTAL);
		separatorH2.setLocation(0, 159);
		separatorH2.setSize(26, 2);
		
		Label separatorH4 = new Label(toolBarLayer, SWT.SEPARATOR | SWT.HORIZONTAL);
		separatorH4.setBounds(0, 276, 26, 2);
		
		Label separatorH3 = new Label(toolBarLayer, SWT.SEPARATOR | SWT.HORIZONTAL);
		separatorH3.setBounds(0, 206, 26, 2);
		
		Label separatorV1 = new Label(toolBarLayer, SWT.SEPARATOR | SWT.VERTICAL);
		separatorV1.setLocation(25, 0);
		separatorV1.setSize(2, 370);

		
		
//		addToolSettingsLayer(parent);

	}
	
	
	
	
	
	
	
	
	
	
	
	private Composite _selectAddLayer = null;
	private Composite _lineAddLayer = null;
	private Composite _pointAddLayer = null;
	
	private Button _btnSelectionTool = null;
	
	private Button _btnConnectPoints = null;
	private Button _btnDisconnectPoints = null;
	
	private Button _btnAddPoint = null;
	private Button _btnAddAndConnect = null;
	private Button _btnRemovePoint = null;
	private Button _btnAddPole = null;
	
	private Label _titleLabel = null;
	
	private static final int LINE_TOOL_CONNECT = 0;
	private static final int LINE_TOOL_DISCONNECT = 1;
	private int _lineToolState = LINE_TOOL_CONNECT;
	
	private static final int POINT_TOOL_ADD = 0;
	private static final int POINT_TOOL_ADD_AND_CONNECT = 1;
	private static final int POINT_TOOL_REMOVE = 2;
	private static final int POINT_TOOL_ADD_POLE = 3;
	private int _pointToolState = POINT_TOOL_ADD;
	
	
	private void showPointToolLayer(){
		_selectAddLayer.setVisible(false);
		_lineAddLayer.setVisible(false);
		_pointAddLayer.setVisible(true);
		_titleLabel.setText("Tool Settings: Point Tool");
		
		switch (_pointToolState){
		case POINT_TOOL_ADD : {
			_btnAddPoint.setSelection(true);
			_btnAddAndConnect.setSelection(false);
			_btnRemovePoint.setSelection(false);
			_btnAddPole.setSelection(false);
			
//			_drawArea.getNodeCollector().setMode(NodeCollector.MODE_ADD);
			break;
		}
		case POINT_TOOL_ADD_AND_CONNECT : {
			_btnAddPoint.setSelection(false);
			_btnAddAndConnect.setSelection(true);
			_btnRemovePoint.setSelection(false);
			_btnAddPole.setSelection(false);
			
//			_drawArea.getNodeCollector().setMode(NodeCollector.MODE_ADD_N_CONNECT);
			break;
		}
		case POINT_TOOL_REMOVE : {
			_btnAddPoint.setSelection(false);
			_btnAddAndConnect.setSelection(false);
			_btnRemovePoint.setSelection(true);
			_btnAddPole.setSelection(false);
			
//			_drawArea.getNodeCollector().setMode(NodeCollector.MODE_REMOVE);
			break;
		}
		case POINT_TOOL_ADD_POLE : {
			_btnAddPoint.setSelection(false);
			_btnAddAndConnect.setSelection(false);
			_btnRemovePoint.setSelection(false);
			_btnAddPole.setSelection(true);
			
//			_drawArea.getNodeCollector().setMode(NodeCollector.MODE_ADD_POLE);
			break;
		}
		default : {
			_btnAddPoint.setSelection(true);
			_btnAddAndConnect.setSelection(false);
			_btnRemovePoint.setSelection(false);
			_btnAddPole.setSelection(false);
			
//			_drawArea.getNodeCollector().setMode(NodeCollector.MODE_ADD);
			break;
		}
		}
	}
	
	private void showSelectToolLayer(){
		_selectAddLayer.setVisible(true);
		_lineAddLayer.setVisible(false);
		_pointAddLayer.setVisible(false);
		
//		_drawArea.getNodeCollector().setMode(NodeCollector.MODE_MOVE);
		_titleLabel.setText("Tool Settings: Selection Tool");
	}
	
	private void showLineToolLayer(){
		_selectAddLayer.setVisible(false);
		_lineAddLayer.setVisible(true);
		_pointAddLayer.setVisible(false);
		_titleLabel.setText("Tool Settings: Line Tool");
		
		switch(_lineToolState){
		case LINE_TOOL_CONNECT : {
			_btnConnectPoints.setSelection(true);
			_btnDisconnectPoints.setSelection(false);
			
//			_drawArea.getNodeCollector().setMode(NodeCollector.MODE_CONNECT);
			break;
		}
		case LINE_TOOL_DISCONNECT : {
			_btnConnectPoints.setSelection(false);
			_btnDisconnectPoints.setSelection(true);
			
//			_drawArea.getNodeCollector().setMode(NodeCollector.MODE_DISCONNECT);
			break;
		}
		default : {
			_btnConnectPoints.setSelection(true);
			_btnDisconnectPoints.setSelection(false);
			
//			_drawArea.getNodeCollector().setMode(NodeCollector.MODE_CONNECT);
			break;
		}
		}
	}
	
//	private void addToolSettingsLayer(Composite parent){
//		//------------------------------------
//		//-----------Setting Menu Layer-------
//		//------------------------------------
//		final Composite settingsLayer = new Composite(parent, SWT.NONE);
//		settingsLayer.setBounds(0, 371, 26, 27);
//		settingsLayer.setBackground(SWTResourceManager.getColor(SWT.COLOR_WIDGET_BACKGROUND));
//		
//		ToolBar toolBar = new ToolBar(settingsLayer, SWT.FLAT | SWT.RIGHT);
//		toolBar.setLocation(0, 2);
//		toolBar.setSize(24, 24);
//		
//		final ToolItem dropItem = new ToolItem(toolBar, SWT.NONE);
//		dropItem.setImage(ResourceManager.getPluginImage("com.jade.editor.object", "icons/IMG_DOWN.png"));
//		dropItem.setToolTipText("Show settings bar");
//		dropItem.addSelectionListener(new SelectionAdapter() {
//			@Override
//			public void widgetSelected(SelectionEvent e) {
//				Rectangle max = new Rectangle(0, 371, 220, 245);
//				Rectangle min = new Rectangle(0, 371, 26, 27);
//
//				
//				if(_showSettingsTabFlag){
//					_showSettingsTabFlag = false;
//					settingsLayer.setSize(settingsLayer.computeSize(min.width, min.height));
//					dropItem.setImage(ResourceManager.getPluginImage("com.jade.editor.object", "icons/IMG_DOWN.png"));
//				}
//				else {
//					_showSettingsTabFlag = true;
//					settingsLayer.setSize(settingsLayer.computeSize(max.width, max.height));
//					dropItem.setImage(ResourceManager.getPluginImage("com.jade.editor.object", "icons/IMG_UP.png"));
//				}
//				
//			}
//		});
//		
//		
//		
//		Label separatorH1m = new Label(settingsLayer, SWT.SEPARATOR | SWT.HORIZONTAL);
//		separatorH1m.setBounds(0, 0, 220, 2);
//		
//		Label separatorH2m = new Label(settingsLayer, SWT.SEPARATOR | SWT.HORIZONTAL);
//		separatorH2m.setBounds(0, 243, 220, 2);
//		
//		Label SeparatorV1m = new Label(settingsLayer, SWT.SEPARATOR | SWT.VERTICAL);
//		SeparatorV1m.setBounds(218, 0, 2, 245);
//		
//		Label separatorV2m = new Label(settingsLayer, SWT.SEPARATOR | SWT.VERTICAL);
//		separatorV2m.setBounds(25, 0, 2, 25);
//		
//		Label separatorH3m = new Label(settingsLayer, SWT.SEPARATOR | SWT.HORIZONTAL);
//		separatorH3m.setBounds(0, 26, 220, 2);
//		
//		_titleLabel = new Label(settingsLayer, SWT.NONE);
//		_titleLabel.setBounds(30, 5, 182, 15);
//		_titleLabel.setText("Tool Settings:");
//		
//		//----------------------------------------------------------------------
//
//		_selectAddLayer = new Composite(settingsLayer, SWT.NONE);
//		_selectAddLayer.setBounds(2, 28, 214, 212);
//		
//		_btnSelectionTool = new Button(_selectAddLayer, SWT.RADIO);
//		_btnSelectionTool.setEnabled(false);
//		_btnSelectionTool.setSelection(true);
//		_btnSelectionTool.setBounds(10, 10, 194, 16);
//		_btnSelectionTool.setText("Selection Tool");
//		
//		
//		
//		
//		_lineAddLayer = new Composite(settingsLayer, SWT.NONE);
//		_lineAddLayer.setBounds(2, 28, 214, 212);
//		
//		_btnConnectPoints = new Button(_lineAddLayer, SWT.RADIO);
//		_btnConnectPoints.setSelection(true);
//		_btnConnectPoints.setBounds(10, 10, 194, 16);
//		_btnConnectPoints.setText("Connect Points");
//		_btnConnectPoints.addSelectionListener(new SelectionAdapter() {
//			@Override
//			public void widgetSelected(SelectionEvent e) {
//				_lineToolState = LINE_TOOL_CONNECT;
//				_drawArea.getNodeCollector().setMode(NodeCollector.MODE_CONNECT);
//			}
//		});
//		
//		_btnDisconnectPoints = new Button(_lineAddLayer, SWT.RADIO);
//		_btnDisconnectPoints.setBounds(10, 32, 194, 16);
//		_btnDisconnectPoints.setText("Disconnect Points");
//		_btnDisconnectPoints.addSelectionListener(new SelectionAdapter() {
//			@Override
//			public void widgetSelected(SelectionEvent e) {
//				_lineToolState = LINE_TOOL_DISCONNECT;
//				_drawArea.getNodeCollector().setMode(NodeCollector.MODE_DISCONNECT);
//			}
//		});
//		
//		
//		
//		_pointAddLayer = new Composite(settingsLayer, SWT.NONE);
//		_pointAddLayer.setBounds(2, 28, 214, 212);
//		
//		_btnAddPoint = new Button(_pointAddLayer, SWT.RADIO);
//		_btnAddPoint.setSelection(true);
//		_btnAddPoint.setBounds(10, 10, 194, 16);
//		_btnAddPoint.setText("Add Point");
//		_btnAddPoint.addSelectionListener(new SelectionAdapter() {
//			@Override
//			public void widgetSelected(SelectionEvent e) {
//				_pointToolState = POINT_TOOL_ADD;
//				_drawArea.getNodeCollector().setMode(NodeCollector.MODE_ADD);
//			}
//		});
//		
//		_btnAddAndConnect = new Button(_pointAddLayer, SWT.RADIO);
//		_btnAddAndConnect.setBounds(10, 32, 194, 16);
//		_btnAddAndConnect.setText("Add and Connect Point");
//		_btnAddAndConnect.addSelectionListener(new SelectionAdapter() {
//			@Override
//			public void widgetSelected(SelectionEvent e) {
//				_pointToolState = POINT_TOOL_ADD_AND_CONNECT;
//				_drawArea.getNodeCollector().setMode(NodeCollector.MODE_ADD_N_CONNECT);
//			}
//		});
//		
//		_btnRemovePoint = new Button(_pointAddLayer, SWT.RADIO);
//		_btnRemovePoint.setBounds(10, 54, 194, 16);
//		_btnRemovePoint.setText("Remove Point");
//		_btnRemovePoint.addSelectionListener(new SelectionAdapter() {
//			@Override
//			public void widgetSelected(SelectionEvent e) {
//				_pointToolState = POINT_TOOL_REMOVE;
//				_drawArea.getNodeCollector().setMode(NodeCollector.MODE_REMOVE);
//			}
//		});
//		
//		_btnAddPole = new Button(_pointAddLayer, SWT.RADIO);
//		_btnAddPole.setBounds(10, 76, 194, 16);
//		_btnAddPole.setText("Add Pole");
//		_btnAddPole.addSelectionListener(new SelectionAdapter() {
//			@Override
//			public void widgetSelected(SelectionEvent e) {
//				_pointToolState = POINT_TOOL_ADD_POLE;
//				_drawArea.getNodeCollector().setMode(NodeCollector.MODE_ADD_POLE);
//			}
//		});
//		
//		Button btnClear = new Button(_pointAddLayer, SWT.NONE);
//		btnClear.setBounds(129, 177, 75, 25);
//		btnClear.setText("Clear");
//		btnClear.addSelectionListener(new SelectionAdapter() {
//			@Override
//			public void widgetSelected(SelectionEvent e) {
//				_drawArea.getNodeCollector().clear();
//			}
//		});
//		
//		switch(_toolSelected){
//		case TOOL_SELECT : {
//			_selectAddLayer.setVisible(true);
//			_lineAddLayer.setVisible(false);
//			_pointAddLayer.setVisible(false);
//			_titleLabel.setText("Tool Settings: Selection Tool");
//			break;
//		}
//		case TOOL_LINE : {
//			_selectAddLayer.setVisible(false);
//			_lineAddLayer.setVisible(true);
//			_pointAddLayer.setVisible(false);
//			_titleLabel.setText("Tool Settings: Line Tool");
//			break;
//			
//		}
//		case TOOL_POINT : {
//			_selectAddLayer.setVisible(false);
//			_lineAddLayer.setVisible(false);
//			_pointAddLayer.setVisible(true);
//			_titleLabel.setText("Tool Settings: Point Tool");
//			break;
//		}
//		default : {
//			_selectAddLayer.setVisible(true);
//			_lineAddLayer.setVisible(false);
//			_pointAddLayer.setVisible(false);
//			_titleLabel.setText("Tool Settings: Selection Tool");
//			break;
//		}
//		
//		}
//	}
}
